<?php
include("../../tools/session.php");
include("../../tools/controls.php");

// 如果登录失败、无权限访问，那么采取相应措施
if (!($is_login_success === true)) { session_hop_page("../index.php"); exit(); }
if (!power_check(0)) { include("tpl-inc-wp.php"); $tpl->display($oa_tpl_path . "/no-power.html"); exit(); }

/*-- 以下是实际内容 --*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="utf-8">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Content-Language" content="UTF-8" />
	<meta content="all" name="robots" />
	<meta name="author" content="tiger"/>
	<meta name="Copyright" content="jinzhou group" />
	<meta name="description" content="jinzhou group oa" />
	<title>文件上传</title>
	<link rel="stylesheet" type="text/css" href="../css/default/doc_template.css" />
</head>
<body>
  <form enctype="multipart/form-data" action="" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
    选择文件: <input name="userfile" type="file" />
    <input type="submit" value="上传" />
</form>
<?php
  // $session_name = "test_person";
  $session_name = $_SESSION["user"]["id"];
  if (!empty($_FILES)){
	 require_once('../../tools/upload.class.php');
	 // $uploadpath = "../upload/" . date("Ym");
	 $uploadpath = "../upload/" . $session_name . "/" . date("Ym");
	 if (!file_exists($uploadpath)) { mkdir($uploadpath, 0777, true); }
	 $f = new upfile($uploadpath, "gif,jpg,jpeg,png,bmp,doc,xls,ppt,txt,pdf,odt");
	 
	 if (isset($_FILES["userfile"])){
		if ($f->upload("userfile", $_FILES["userfile"]["name"])){
		   echo "<span style=\"color:green;\">上传成功！</span>";
		   echo "<script language=\"javascript\">window.parent.upload_file_succ('" . $uploadpath . "/" . $f->savename . "');</script>";
		}
	 }
  }
?>
</body>
</html>

